<div class="content-section introduction">
    <div>
        <span class="feature-title">ColorPicker</span>
        <span>ColorPicker is an input component to select a color.</span>
    </div>
</div>

<div class="content-section implementation">
    <h3 class="first">Inline</h3>
    <p-colorPicker [(ngModel)]="color1" inline="true"></p-colorPicker>
    
    <p style="margin-top:.5em">Selected Color: <span style="display:inline-block;width:32px;height:32px;vertical-align:middle" [style.backgroundColor]="color1"></span> {{color1}} </p>    
    
    <h3>Overlay</h3>
    <p-colorPicker [(ngModel)]="color2"></p-colorPicker>
    
    <p style="margin-top:.5em">Selected Color: <span [ngStyle]="{'color':color2}">{{color2}}</span></p> 
</div>

<div class="content-section documentation">
    <p-tabView effect="fade">
        <p-tabPanel header ="Documentation">
            <h3>Import</h3>
<pre>
<code class="language-typescript" pCode ngNonBindable>
import &#123;ColorPickerModule&#125; from 'primeng/primeng';
</code>
</pre>

            <h3>Getting Started</h3>
            <p>ColorPicker uses ngModel directive to bind a value.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-colorPicker [(ngModel)]="color"&gt;&lt;/p-colorPicker&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class MyComponent &#123;

    color: string;

&#125;
</code>
</pre>

            <h3>Formats</h3>
            <p>Default color format to use in value binding is "hex" and other possible values are "rgb" and "hsb". 
                Example below has 3 colorpickers having default values with different formats.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-colorPicker [(ngModel)]="color1"&gt;&lt;/p-colorPicker&gt;
&lt;p-colorPicker [(ngModel)]="color2" format="rgb"&gt;&lt;/p-colorPicker&gt;
&lt;p-colorPicker [(ngModel)]="color3" format="hsb"&gt;&lt;/p-colorPicker&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class MyComponent &#123;

    color1: string;
    
    color2: any = &#123;
        r: 100, g: 130, b: 150
    &#125;;
    
    color3: any = &#123;
        h: 100, s: 50, b: 50
    &#125;;

&#125;
</code>
</pre>

            <h3>Overlay and Inline</h3>
            <p>ColorPicker can be displayed as inline or as an overlay (default) using the "inline" property.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-colorPicker [(ngModel)]="color1" &gt;&lt;/p-colorPicker&gt;
&lt;p-colorPicker [(ngModel)]="color2" inline="true"&gt;&lt;/p-colorPicker&gt;
</code>
</pre>

            <h3>Model Driven Forms</h3>
            <p>Dropdown can be used in a model driven form as well.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-colorPicker formControlName="color"&gt;&lt;/p-dropdown&gt;
</code>
</pre>
            
    
            <h3>Properties</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                        <tr>
                            <td>inline</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>Whether to display as an overlay or not.</td>
                        </tr>
                        <tr>
                            <td>format</td>
                            <td>string</td>
                            <td>hex</td>
                            <td>Format to use in value binding, supported formats are "hex", "rgb" and "hsb".</td>
                        </tr>
                        <tr>
                            <td>appendTo</td>
                            <td>any</td>
                            <td>null</td>
                            <td>Target element to attach the overlay, valid values are "body" or a local ng-template variable of another element.</td>
                        </tr>
                        <tr>
                            <td>tabindex</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Index of the element in tabbing order.</td>
                        </tr>
                        <tr>
                            <td>disabled</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that the component should be disabled.</td>
                        </tr>
                        <tr>
                            <td>inputId</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Identifier of the focus input to match a label defined for the dropdown.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

        <h3>Events</h3>
        <div class="doc-tablewrapper">
            <table class="doc-table">
                <thead>
                <tr>
                    <th>Name</th>
                    <th>Parameters</th>
                    <th>Description</th>
                </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>onChange</td>
                        <td>event.originalEvent: Browser event<br />
                            event.value: Selected color
                        </td>
                        <td>Callback to invoke when a color is selected.</td>
                    </tr>
                </tbody>
            </table>
        </div>

        <h3>Styling</h3>
        <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
        <div class="doc-tablewrapper">
            <table class="doc-table">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Element</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>ui-colorpicker</td>
                        <td>Container element.</td>
                    </tr>
                    <tr>
                        <td>ui-colorpicker-overlay</td>
                        <td>Container element in overlay mode.</td>
                    </tr>
                    <tr>
                        <td>ui-colorpicker-preview </td>
                        <td>Preview input in overlay mode.</td>
                    </tr>
                    <tr>
                        <td>ui-colorpicker-panel</td>
                        <td>Panel element of the colorpicker.</td>
                    </tr>
                    <tr>
                        <td>ui-colorpicker-content</td>
                        <td>Wrapper that contains color and hue sections.</td>
                    </tr>
                    <tr>
                        <td>ui-colorpicker-color-selector</td>
                        <td>Color selector container.</td>
                    </tr>
                    <tr>
                        <td>ui-colorpicker-color</td>
                        <td>Color element.</td>
                    </tr>
                    <tr>
                        <td>ui-colorpicker-color-handle</td>
                        <td>Handle of the color element.</td>
                    </tr>
                    <tr>
                        <td>ui-colorpicker-hue</td>
                        <td>Hue slider.</td>
                    </tr>
                    <tr>
                        <td>ui-colorpicker-hue-handle</td>
                        <td>Handle of the hue slider.</td>
                    </tr>
                </tbody>
            </table>
        </div>

        <h3>Dependencies</h3>
        <p>None.</p>

        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/colorpicker" class="btn-viewsource" target="_blank">
                <i class="fa fa-github"></i>
                <span>View on GitHub</span>
            </a>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;h3 class="first"&gt;Inline&lt;/h3&gt;
&lt;p-colorPicker [(ngModel)]="color1" inline="true"&gt;&lt;/p-colorPicker&gt;

&lt;p style="margin-top:.5em"&gt;Selected Color: &lt;span style="display:inline-block;width:32px;height:32px;vertical-align:middle" [style.backgroundColor]="color1"&gt;&lt;/span&gt; &#123;&#123;color1&#125;&#125; &lt;/p&gt;    

&lt;h3&gt;Overlay&lt;/h3&gt;
&lt;p-colorPicker [(ngModel)]="color2"&gt;&lt;/p-colorPicker&gt;

&lt;p style="margin-top:.5em"&gt;Selected Color: &lt;span [ngStyle]="&#123;'color':color2&#125;"&gt;&#123;&#123;color2&#125;&#125;&lt;/span&gt;&lt;/p&gt; 
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class ColorPickerDemo &#123;

    color1: string;
    
    color2: string = '#1976D2';
&#125;
</code>
</pre>
        </p-tabPanel>
    </p-tabView>
</div>
